
import Router from 'vue-router'

import HomeLayout from '@/layout/home-layout'
// import SingleLayout from '../layout/single-layout'

import store from '@/store'

/* --------------------------------------------------------------------------------- */
/* -----------------------------  配置路由  ---------------------------------- */
/* --------------------------------------------------------------------------------- */


import page_list from './_page_load'
import _auto_page_generate from './_auto_page_generate'
// import page_list from './page_load_stand'

const routes = [
  {
    path: '/',
    component: HomeLayout,
  },
  {
    path: "",
    component: HomeLayout
  },

  // 带菜单的配置页
  {
    path: '/page/*',
    name: 'HomeLayout',
    component: HomeLayout,
    children: [
      ...page_list,
      ..._auto_page_generate.map(it => {
        let { component, ...routeItem } = it
        return routeItem
      }),
      {
        path: '*',
        redirect: '/page/base/not_found',
      },
    ],
  },
  {
    path: '*',
    redirect: '/page/base/not_found',
  },
]

import Vue from 'vue'
Vue.use(Router)

const RouterInstance = new Router({
  base: '/',
  mode: 'history',
  routes: routes
})


RouterInstance.beforeEach((to, from, next) => {

  if (store.state.stopRoute != true) {
    store.commit("routerFrom", from)
    next()
  } else {

  }


})
export default RouterInstance


